package cn.webrx;

public class Num1 {
    public static void main(String[] args) {
        int n = 10;
        //十进制转换二进制
        System.out.println(Integer.toBinaryString(n)); //1010
        //十进制转换八进制
        System.out.println(Integer.toOctalString(n));// 12
        //十进制转换十六进制
        System.out.println(Integer.toHexString(n));//a
        System.out.println(Integer.toHexString(255));//ff

        //十六进制，返回十进制
        int nn = 0xff;
        System.out.println(nn);//255
        System.out.println(Integer.valueOf("ff",16));//255

        //二进制，返回十进制
        System.out.println(0b1010); //10
        int bb = 0b1011;
        System.out.println(bb);//11
        System.out.println(Integer.valueOf("1111",2));//15

        //八进制，返回十进制
        int tt = 012;
        System.out.println(tt);//10
        System.out.println(012); //10
        System.out.println(Integer.valueOf("12",8));//10

    }
}
